<template>
  <!-- 综合满意度页面 -->
  <div class="list-box">
    <div class="top-box">
      <div class="title-box">
        <img src="../../assets/pan-view/编组 2.png" />
        <div>商业过程</div>
      </div>
      <div class="item-box" v-for="(item, index) in listData" :key="index">
        <div class="item-top">
          <div class="box">
            <van-icon name="after-sale" color="rgb(238, 134, 50)" size="18" />
            <div>{{ item.title }}</div>
          </div>
          <div class="order">
            排名
            <div>{{ item.orders }}</div>
          </div>
        </div>
        <div class="item-bottom">
          <div class="value-box">
            <div class="kpi-value">{{ item.kpiValue }}</div>
            <van-progress
              pivot-text=""
              color="#FE6800"
              :percentage="item.kpiValue"
              stroke-width="10"
            />
          </div>
          <div class="value-box">
            <div class="value">{{ item.value }}</div>
            <div class="title">{{ item.valueTitle }}</div>
          </div>
          <div class="value-box">
            <div
              class="value"
              :class="isNegative(item.hb) ? 'value-green' : 'value-yellow'"
            >
              {{ item.hb }}
              <img
                v-if="isNegative(item.hb)"
                src="../../assets/pan-view/up.png"
              />
              <img v-else src="../../assets/pan-view/up(1).png" />
            </div>
            <div class="title">{{ item.hbTitlte }}</div>
          </div>
        </div>
      </div>
    </div>

    <div class="center-box">
      <div class="title-box">
        <div class="box">
          <img src="../../assets/pan-view/编组 2.png" />
          <div>领先情况</div>
        </div>
        <div v-if="active == '0'" class="right-box">
          <div class="right-box value1">领先电信 1.15</div>
          <div class="right-box value2">
            环比
            <span>-1.15%</span>
          </div>
        </div>
      </div>
      <van-tabs
        style="margin-top: 10px; border: 0px"
        v-model:active="active"
        type="card"
        background="#F3F3F3"
        color="#FE6800"
        title-active-color="#FFFFFF"
        title-inactive-color="#333333"
        @click-tab="onClickTab"
      >
        <van-tab title="排名 1"></van-tab>
        <van-tab title="排名 2"></van-tab>
        <van-tab title="排名 3"></van-tab>
      </van-tabs>

      <div class="content-box">
        <div class="operator-box">
          <div class="operator-icon-box">
            <div class="icon" v-if="active == 0"></div>
            <div class="icon1" v-else-if="active == 1"></div>
            <div class="icon2" v-else></div>
          </div>
          <div class="operator-value-box">
            <div class="value">89.38</div>
            <div class="title">表现值</div>
          </div>

          <div class="operator-value-box">
            <div
              class="value"
              :class="isNegative('-1.61%') ? 'value-green' : 'value-yellow'"
            >
              -1.61%
              <img
                v-if="isNegative('-1.61%')"
                src="../../assets/pan-view/up.png"
              />
              <img v-else src="../../assets/pan-view/up(1).png" />
            </div>
            <div class="title">表现值</div>
          </div>
        </div>
        <lineEcharts :chartObj="chartObj" :cindex="100001" />
      </div>
    </div>

    <div class="bottom-box">
      <div class="title-box">
        <img src="../../assets/pan-view/编组 2.png" />
        <div>业务</div>
      </div>

      <div class="item-box">
        <!-- 手机业务 -->
        <div class="bottom-item-box">
          <div class="title-box">
            <div class="title-left-box">
              <div class="title">手机业务</div>
              <div class="line"></div>
            </div>
            <img src="../../assets/pan-view/top2.png" />
          </div>
          <div class="value">83.83</div>
          <div class="value2-box">领先电信 2.05</div>
          <div class="value2-box">
            环比
            <div :class="isNegative('-2.05%') ? 'value-yellow' : 'value-green'">
              -2.05%
            </div>
            <img
              v-if="isNegative('-2.05%')"
              src="../../assets/pan-view/up(1).png"
            />
            <img v-else src="../../assets/pan-view/up.png" />
          </div>
        </div>
        <!-- 固定宽带 -->
        <div class="bottom-item-box">
          <div class="title-box">
            <div class="title-left-box">
              <div class="title">固定宽带</div>
              <div class="line"></div>
            </div>
            <img src="../../assets/pan-view/top3.png" />
          </div>
          <div class="value">83.83</div>
          <div class="value2-box">领先电信 2.05</div>
          <div class="value2-box">
            环比
            <div :class="isNegative('-2.05%') ? 'value-yellow' : 'value-green'">
              -2.05%
            </div>
            <img
              v-if="isNegative('-2.05%')"
              src="../../assets/pan-view/up(1).png"
            />
            <img v-else src="../../assets/pan-view/up.png" />
          </div>
        </div>
        <!-- 固定语音 -->
        <div class="bottom-item-box">
          <div class="title-box">
            <div class="title-left-box">
              <div class="title">固定语音</div>
              <div class="line"></div>
            </div>
            <img src="../../assets/pan-view/top1.png" />
          </div>
          <div class="value">83.83</div>
          <div class="value2-box">领先电信 2.05</div>
          <div class="value2-box">
            环比
            <div :class="isNegative('-2.05%') ? 'value-yellow' : 'value-green'">
              -2.05%
            </div>
            <img
              v-if="isNegative('-2.05%')"
              src="../../assets/pan-view/up(1).png"
            />
            <img v-else src="../../assets/pan-view/up.png" />
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import "@/api/index";
import { ref, reactive, toRefs, onMounted } from "vue";
import store from "@/store/index";
import { useRouter } from "vue-router";
import { Toast } from "vant";
import * as echarts from "echarts";
import lineEcharts from "@/components/lineEcharts.vue";

export default {
  components: { lineEcharts },
  props: ["jsonData"],
  setup(props) {
    console.log(props.jsonData.chartObj);
    let state = reactive({
      active: 0,
      chartObj: props.jsonData.chartObj,
      listData: props.jsonData.listData,
    });

    const onClickTab = ({ name, title }) => {
      console.log(name);
      state.active = name;
    };

    //判断是否为负数
    function isNegative(num) {
      if (!num) return true;
      num = num + "";
      if (num.indexOf("-") != -1 && num != "-") return true;
      return false;
    }

    onMounted(() => {
      // state.chartObj = {
      //   title: "手厅",
      //   index: 2,
      //   yAxisData: [213, 326, 430, 266, 330, 538, 640, 830, 466, 230],
      //   xAxisData: [
      //     "10/01",
      //     "10/02",
      //     "10/03",
      //     "10/04",
      //     "10/05",
      //     "10/06",
      //     "10/07",
      //     "10/08",
      //     "10/09",
      //     "10/10",
      //   ],
      // };
    });

    return {
      ...toRefs(state),
      isNegative,
      onClickTab,
    };
  },
};
</script>

<style lang="scss" scoped>
.list-box {
  margin-top: 10px;
  width: 100%;
  height: calc(100% - 154px);
  padding-bottom: 10px;
  overflow: auto;

  .title-box {
    padding: 10px;
    display: flex;
    align-items: center;

    img {
      height: 24px;
      width: 24px;
    }

    div {
      color: #333333;
      font-size: 16px;
      font-weight: 400;
    }
  }

  .top-box {
    margin: 10px;
    border-radius: 8px;
    background: #ffffff;

    .item-box {
      margin: 10px;
      padding: 10px;
      height: 108px;
      background: #fffaf4;
      border-radius: 8px;

      .item-top {
        display: flex;
        justify-content: space-between;

        .box {
          display: flex;
          font-size: 14px;
          color: #333333;
          align-items: center;
          div {
            margin-left: 8px;
          }
        }

        .order {
          display: flex;
          width: 66px;
          height: 24px;
          background: #ffffff;
          box-shadow: inset 0px 0px 2px 0px rgba(254, 106, 0, 0.3);
          border-radius: 4px;
          font-size: 12px;
          color: #fe6a00;
          align-items: center;
          justify-content: center;
          div {
            margin-left: 5px;
            font-size: 14px;
          }
        }
      }

      .item-bottom {
        display: flex;
        width: 100%;

        .value-box {
          width: 33%;
          display: flex;
          flex-direction: column;
          //   justify-content: center;
          //   align-items: center;
          .kpi-value {
            margin: 10px;
            color: #fe6a00;
            font-size: 20px;
            font-family: Helvetica-Bold, Helvetica;
            font-weight: bold;
            text-align: center;
          }

          .value {
            display: flex;
            align-items: center;
            justify-content: center;
            margin: 10px;
            font-size: 18px;
            font-family: Helvetica-Bold, Helvetica;
            font-weight: bold;
            color: #333333;
            line-height: 24px;
          }

          .value-yellow {
            color: #e34343;
          }

          .value-green {
            color: #10cfa5;
          }

          .title {
            font-size: 12px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #666666;
            line-height: 16px;
            text-align: center;
          }
        }
      }
    }
  }

  .center-box {
    margin: 10px;
    padding: 10px;
    height: 360px;
    background: #ffffff;
    border-radius: 8px;
    .title-box {
      display: flex;
      justify-content: space-between;

      .box {
        display: flex;
        font-size: 14px;
        color: #333333;
        align-items: center;
        font-size: 16px;
        font-weight: 400;

        img {
          height: 24px;
          width: 24px;
        }
        div {
          margin-left: 4px;
        }
      }

      .right-box {
        display: flex;
        height: 24px;
        align-items: center;
        justify-content: center;

        .value1 {
          background: #fffaf4;
          color: #fe6a00;
        }

        .value2 {
          background: #f3f3f3;
          color: #333333;

          span {
            margin-left: 5px;
            color: #e34343;
          }
        }

        .value3 {
          color: #e34343;
        }
        div {
          display: flex;
          align-items: center;
          width: 96px;
          height: 24px;
          font-size: 14px;
          border-radius: 4px;
          font-size: 12px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
        }
      }
    }

    .content-box {
      position: relative;
      padding: 10px;
      margin-top: 1px;
      background: #ffffff;
      width: 100%;
      height: calc(100% - 88px);

      .operator-box {
        width: 100%;
        display: flex;
        height: 48px;
        justify-content: space-around;

        .operator-icon-box {
          width: 45%;
          display: flex;

          .icon {
            width: 100%;
            height: 100%;
            background: url("../../assets/pan-view/中国移动 (6).png") no-repeat
              0 0;
          }

          .icon1 {
            width: 100%;
            height: 100%;
            background: url("../../assets/pan-view/电信.png") no-repeat 0 0;
          }

          .icon2 {
            width: 100%;
            height: 100%;
            background: url("../../assets/pan-view/联通.png") no-repeat 0 0;
          }
        }

        .operator-value-box {
          width: 25%;
          display: flex;
          flex-direction: column;
          align-items: center;
          justify-content: space-around;

          .title {
            font-size: 12px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #666666;
          }

          .value {
            display: flex;
            font-size: 18px;
            font-family: Helvetica;
            color: #333333;
          }

          .value-yellow {
            color: #e34343;
          }

          .value-green {
            color: #10cfa5;
          }
        }
      }

      .operator-charts {
        margin-top: 10px;
        width: 100%;
        height: 200px;
      }
    }
  }

  .bottom-box {
    margin: 10px;
    padding: 10px;
    height: 196px;
    background: #ffffff;
    border-radius: 8px;

    .item-box {
      display: flex;
      justify-content: space-around;
    }

    .bottom-item-box {
      width: 31%;
      height: 128px;
      background: #f3f3f3;
      border-radius: 4px;
      border: 0px solid #979797;

      .title-box {
        display: flex;
        justify-content: space-between;
        align-items: center;
        .title-left-box {
          .title {
            font-size: 12px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #333333;
          }
          .line {
            margin-top: 5px;
            width: 16px;
            height: 4px;
            background: #ff9900;
            border-radius: 2px;
            border: 0px solid #979797;
          }
        }
        img {
          width: 24px;
          height: 24px;
        }
      }

      .value {
        margin-top: 10px;
        margin-bottom: 10px;
        width: 100%;
        font-size: 21px;
        font-family: Helvetica-Bold, Helvetica;
        font-weight: bold;
        color: #333333;
        text-align: center;
      }

      .value2-box {
        margin: 8px;
        background: #ffffff;
        width: calc(100% - 16px);
        height: 14px;
        display: flex;
        font-size: 10px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #666666;
        justify-content: center;
        align-items: center;

        div {
          margin-left: 4px;
          margin-right: 4px;
        }

        img {
          height: 12px;
          width: 8px;
        }

        .value-yellow {
          color: #e34343;
        }

        .value-green {
          color: #10cfa5;
        }
      }
    }
  }
}

:v-deep .van-tab--active {
  color: #ffffff !important;
}
</style>
